package com.xbongbong.paas.enums;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import lombok.Getter;
import org.springframework.util.CollectionUtils;

/**
 * 自定义报表对应的es字段
 * @author 梁鲁江
 * @version v1.0
 * @date 2020/4/1 16:12
 * @since v1.0
 */
@Getter
public enum BiEsAliasEnum {
    /**
     * EsAlias
     */
    TEXT("text","String","文本",100),

    NUM("num","Double","数字",50),
    /**
     * 现在地址和定位的存储无差别
     */
    LOCATION("location", "JSONObject","地址",4),

    DATE("date","Long","日期",20),

    SUB_FORM("subForm", "JSONArray","子表单",10),

    MY_TEAM("myTeam", "JSONArray","团队",10),

    FILE("file","String","文件",10),

    ARRAY("array","JSONArray","数组",50),

    /**
     * id类，比如
     */
    ID("id","Long","id",20),

    DATAID("dataId","Long","dataId",20),
    /**
     * 表单id
     */
    FORMID("formId","Long","表单Id",6),
    /**
     * 编号
     */
    SERIALNO("serialNo","String","编号",6),
    /**
     * 拥有者id
     */
    OWNERID("ownerId","Long","拥有者id",6),
    /**
     * 部门id
     */
    DEPARTMENTID("departmentId","Long","部门id",6),
    /**
     * 流程状态枚举值
     */
    FLOWSTATUS("flowStatus","Integer","流程状态枚举值",6),
    /**
     * 状态枚举值
     */
    STATUS("status","Integer","状态枚举值",6),
    /**
     * 创建者id
     */
    CREATORID("creatorId","Long","创建者id",6),
    ;
    BiEsAliasEnum(String esAlias, String type,String description, Integer max) {
        this.esAlias = esAlias;
        this.type = type;
        this.description = description;
        this.max = max;
    }

    /**
     * 字段
     */
    private String esAlias;
    /**
     * 类型
     */
    private String type;
    /**
     * 字段描述
     */
    private String description;
    /**
     * 最大个数
     */
    private Integer max;

    public static BiEsAliasEnum getByEsAlias(String esAlias){
        for (BiEsAliasEnum e : values()) {
            if (e.getEsAlias().equals(esAlias)) {
                return e;
            }
        }
        return null;
    }

    static int count = 0;
    public static void main(String[] args) {
        for (BiEsAliasEnum value : values()) {
            for(int i= 1;i<=value.getMax();i++){
                String str = "private "+value.getType()+" "+ value.getEsAlias()+ "_" +i+";";
                System.out.println(str);
               count ++;
            }
        }
        System.out.println(count);
    }
}
